#include "copymakeborder_plugin.h"
#include "ui_plugin.h"
#include <QtGlobal>

CopyMakeBorder::CopyMakeBorder()
{
}

CopyMakeBorder::~CopyMakeBorder()
{

}

QString CopyMakeBorder::title(void)
{
    return this->metaObject()->className();
    //return "";
}

QString CopyMakeBorder::help(void)
{
    return "";
}

QString CopyMakeBorder::description(void)
{
    return "";
}

QString CopyMakeBorder::version(void)
{
    return tr("1.0.0");
}

void CopyMakeBorder::setupUi(QWidget* parent)
{

    ui = new Ui::PluginGui;
    ui->setupUi(parent);
    QStringList items;
    items.append("BORDER_CONSTANT");
    items.append("BORDER_REPLICATE");
    items.append("BORDER_REFLECT");
    items.append("BORDER_WRAP");
    items.append("BORDER_REFLECT_101");
    ui->borderTypeComboBox->addItems(items);
    connect(ui->borderTypeComboBox,
            SIGNAL(currentIndexChanged(int)),
            this,
            SLOT(on_borderTypeComboBox_currentIndexChanged(int)));
    qDebug("haha...\r\n");

}
void CopyMakeBorder::processImage(const cv::Mat & input, cv::Mat & output)
{
    int top, bot, left, right;
    top = bot = input.rows/2;
    left = right = input.cols/2;
    cv::copyMakeBorder(input,
                   output,
                   top,
                   bot,
                   left,
                   right,
                   ui->borderTypeComboBox->currentIndex());

}

void CopyMakeBorder::on_borderTypeComboBox_currentIndexChanged(int index)
{
    Q_UNUSED(index);
    qDebug("%s, index:%d\r\n", __func__, index);
    emit updateNeeded();
}
